/*
 * Copyright (c) 2009, Hamish Morgan. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * 3. Neither the name of the University of Sussex nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package locusts.common.entities;

import java.awt.Shape;
import java.awt.geom.Area;
import locusts.lib.geom.Shapes;
import locusts.server.behaviours.Behaviour;

/**
 *
 * @author Hamish Morgan
 */
public class EntityData {

    private static final Behaviour DEFAULT_BEHAVIOUR = null;
    private static final Shape DEFAULT_SHAPE = null;
    private static final double DEFAULT_MASS = 1;
    private static final double DEFAULT_MAX_ENERGY = 100;
    private static final double DEFAULT_MIN_ENERGY = 0;
    private static final boolean DEFAULT_DIE_ON_ZERO_ENERGY = true;
    private static final double DEFAULT_ENERGY_DEPLETION_RATE = 0.05;
    //
    //
    private Behaviour behaviour;
    private Shape shape;
    private double maxRadius;
    private Area area;
    private double mass;
    private double maxEnergy;
    private double minEnergy;
    private boolean dieOnZeroEnergy;
    private double energyDepletionRate;

    public EntityData(Behaviour behaviour, Shape shape, double radius,
            double mass) {
        this.behaviour = behaviour;
        this.shape = shape;
        this.area = shape == null ? null : new Area(shape);
        this.maxRadius = radius;
        this.mass = mass;
        this.maxEnergy =DEFAULT_MAX_ENERGY;
        this.minEnergy = DEFAULT_MIN_ENERGY;
        this.dieOnZeroEnergy = DEFAULT_DIE_ON_ZERO_ENERGY;
        this.energyDepletionRate = DEFAULT_ENERGY_DEPLETION_RATE;
    }

    public EntityData(Behaviour behaviour, Shape shape) {
        this(behaviour, shape, Shapes.calculateMaxRadius(shape), DEFAULT_MASS);
    }

    public EntityData() {
        this(DEFAULT_BEHAVIOUR, DEFAULT_SHAPE);
    }

    public double getEnergyDepletionRate() {
        return energyDepletionRate;
    }

    public void setEnergyDepletionRate(double energyDepletionRate) {
        this.energyDepletionRate = energyDepletionRate;
    }
    
    public boolean isDieOnMinEnergy() {
        return dieOnZeroEnergy;
    }

    public void setDieOnMinEnergy(boolean dieOnZeroEnergy) {
        this.dieOnZeroEnergy = dieOnZeroEnergy;
    }

    public double getMaxEnergy() {
        return maxEnergy;
    }

    public void setMaxEnergy(double maxEnergy) {
        this.maxEnergy = maxEnergy;
    }

    public double getMinEnergy() {
        return minEnergy;
    }

    public void setMinEnergy(double minEnergy) {
        this.minEnergy = minEnergy;
    }
    
    public Behaviour getBehaviour() {
        return behaviour;
    }

    public void setBehaviour(Behaviour behaviour) {
        this.behaviour = behaviour;
    }

    public boolean isBehaviourSet() {
        return behaviour != null;
    }

    public double getMass() {
        return mass;
    }

    public void setMass(double mass) {
        this.mass = mass;
    }

    public Shape getShape() {
        return shape;
    }

    public Area getArea() {
        return area;
    }

    public void setShape(Shape shape) {
        this.shape = shape;
        this.maxRadius = Shapes.calculateMaxRadius(shape);
        this.area = new Area(shape);
    }

    public double getMaxRadius() {
        return maxRadius;
    }

    public void setMaxRadius(double maxRadius) {
        this.maxRadius = maxRadius;
    }

  
}
